package com.estate.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.SessionFactory;

import com.estate.dao.ProFileDao;
import com.estate.vo.Vo;
import com.estate.vo.impl.ProFileVo;

public class ProFileDaoImpl implements ProFileDao {
	
	private SessionFactory sessionFactory;
	
	public SessionFactory getSessionFactory(){
		return this.sessionFactory;
	}
	
	public void setSessionFactory(SessionFactory sessionFactory){
		this.sessionFactory=sessionFactory;
	}

	public boolean addVo(Vo vo) {
		// TODO Auto-generated method stub
		this.getSessionFactory().getCurrentSession().save(vo);
		return false;
	}

	public boolean deleteVo(Vo vo) {
		// TODO Auto-generated method stub
		this.getSessionFactory().getCurrentSession().delete(vo);
		return false;
	}

	public List<Vo> findAll() {
		// TODO Auto-generated method stub
		Query query=this.getSessionFactory().getCurrentSession().createQuery("from ProFileVo");
		List<Vo> voList=query.list();
		return voList;
	}

	public Vo findByPK(Object pk) {
		// TODO Auto-generated method stub
		return (Vo)this.getSessionFactory().getCurrentSession().get(ProFileVo.class, (Integer)pk);
	}

	public boolean updateVo(Vo vo) {
		// TODO Auto-generated method stub
		this.getSessionFactory().getCurrentSession().update(vo);
		return false;
	}

	public List<Vo> getFilesByPro(int catagory, int id) {
		// TODO Auto-generated method stub
		Query query=this.getSessionFactory().getCurrentSession().createQuery("from ProFileVo where proCatagory=:catagory and proId=:id").setInteger("catagory", catagory).setInteger("id", id);
		List<Vo> voList=query.list();
		return voList;
	}

}
